package com.sinodata.bsm.cicp.collector.informix;

import java.io.BufferedReader;
import java.util.List;

import com.sinodata.bsm.cicp.collector.Collector;
import com.sinodata.bsm.cicp.exception.CollectorException;
import com.sinodata.bsm.cicp.util.CommandReader;
import com.sinodata.bsm.cicp.util.ProtocolParameterUtil;
import com.sinodata.bsm.common.vo.ProtocolParameter;
import com.sinodata.bsm.common.vo.ResPropertyValue;

/**
 * 
 * <p>
 * Description: 比较com_sys_parm中的时间sys_date 与  主机的时间 是否一致
 * </p>
 *
 * @author wangyazhou
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2013-2-22 下午4:35:39          wangyazhou        1.0         To create
 * </p>
 *
 * @since 
 * @see
 */
public class SysdateCollector extends Collector {

    private String cmd = "echo  date=`date`;echo sys=`cat .txt`";

    @Override
    public String[] getPropMeta() {
        return new String[] { "" };
    }

    @Override
    public String[] getParamMeta() {
        return new String[] { "$1", "$2", "$3" };
    }

    @Override
    public List<ResPropertyValue> collect(String ip) throws CollectorException {
        ProtocolParameter protocolParameter = ProtocolParameterUtil.getHostValue(ip);
        BufferedReader reader = null;
        String date = null;
        String sysdate = null;

        try {
            reader = CommandReader.getReader(ip, cmd, 0, 0);
            String strLine = null;
            while ((strLine = reader.readLine()) != null) {
                if (strLine.matches("^date=.*")) {
                    date = strLine.substring(0, "date=".length());
                }
                if (strLine.matches("^sys=.*")) {
                    sysdate = strLine.substring(0, "sys=".length());
                }
            }

        } catch (Exception e) {
            logger.error("OnlineLogCollector produc error where save currFileSize");
            throw new CollectorException(e);
        }
        return null;
    }
}
